package com.shuai.shuaisecondhand_springboot.service;

import com.shuai.shuaisecondhand_springboot.entity.Leave;
import com.shuai.shuaisecondhand_springboot.mapper.LeaveMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LeaveService {

    @Autowired
    LeaveMapper leaveMapper;

    //插入
    public Boolean insertLeave(@Param("Uid") String Uid, @Param("Gid") String Gid, @Param("message") String message) {
        try {
            return leaveMapper.insertLeave(Uid, Gid, message);
        } catch (Exception e) {
            return false;
        }
    }

    //删除
    public Integer deleteLeave(long Lid, long Sid) {
        return leaveMapper.deleteLeave(Lid, Sid);
    }

    //根据Gid查询数据
    public List<Leave> getLeavePage(Integer pageNum, Integer pageSize, String Gid) {
        return leaveMapper.getLeavePage(pageNum, pageSize, Gid);
    }

    //查询Gid的所有数据量
    public int getGidTotal(String Gid) {
        return leaveMapper.getGidTotal(Gid);
    }


    //根据Sid查询数据
    public List<Leave> getLeavePageUid(Integer pageNum, Integer pageSize, String Uid) {
        return leaveMapper.getLeavePageUid(pageNum, pageSize, Uid);
    }

    //查询Gid的所有数据量
    public int getUidTotal(String Uid) {
        return leaveMapper.getUidTotal(Uid);
    }
}
